#include <bits/stdc++.h>
using namespace std;
int T;
const int N=1e5+5;
int n,m,L,V;
int highspeedcarcount=0;
int d[N],v[N],a[N],p[N];
int check(int tmp){
    tmp=0;
    for(int i=1;i<=n;i++){
        cin>>d[i]>>v[i]>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>p[i];
    }
    for(int i=1;i<=n;i++){
        if(a[i]==0){
            for(int j=1;j<=m;j++){
                if(d[i]>p[j]){
                    continue;
                }
                double carspeed=0;
                carspeed=sqrt(pow(v[i],2)+2*a[i]*(p[j]-d[i]));
                if(carspeed>V) {
                    tmp++;
                    break;
                }
            }
        }
        if(a[i]>0) {
            for(int j=1;j<=m;j++){
                if(d[i]>p[j]){
                    continue;
                }
                double carspeed=0;
                carspeed=sqrt(pow(v[i],2)+2*a[i]*(p[j]-d[i]));
                if(carspeed>V) {
                    tmp++;
                    break;
                }
            }
        }
        if(a[i]<0){
            for(int j=1;j<=m;j++){
                if(d[i]>p[j]){
                    continue;
                }
                double carspeed=0;
                carspeed=sqrt(pow(v[i],2)+2*a[i]*(p[j]-d[i]));
                if(carspeed>V) {
                    tmp++;
                    break;
                }
            }
        }
    }
    return tmp;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        cout<<check(highspeedcarcount)<<" ";
        if(d[n]>p[m]){
            cout<<m-2<<endl;
        }
        else{
            cout<<m-1<<endl;
        }
    }
    return 0;
}
